package com.ruoyi.car.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.car.domain.CarCommunityReply;
import com.ruoyi.car.service.ICarCommunityReplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社区回复Controller
 * 
 * @author ruoyi
 * @date 2024-04-07
 */
@RestController
@RequestMapping("/car/reply")
public class CarCommunityReplyController extends BaseController
{
    @Autowired
    private ICarCommunityReplyService carCommunityReplyService;

    /**
     * 查询社区回复列表
     */
    @PreAuthorize("@ss.hasPermi('car:reply:list')")
    @GetMapping("/list")
    public TableDataInfo list(CarCommunityReply carCommunityReply)
    {
        startPage();
        List<CarCommunityReply> list = carCommunityReplyService.selectCarCommunityReplyList(carCommunityReply);
        return getDataTable(list);
    }

    /**
     * 导出社区回复列表
     */
    @PreAuthorize("@ss.hasPermi('car:reply:export')")
    @Log(title = "社区回复", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarCommunityReply carCommunityReply)
    {
        List<CarCommunityReply> list = carCommunityReplyService.selectCarCommunityReplyList(carCommunityReply);
        ExcelUtil<CarCommunityReply> util = new ExcelUtil<CarCommunityReply>(CarCommunityReply.class);
        util.exportExcel(response, list, "社区回复数据");
    }

    /**
     * 获取社区回复详细信息
     */
    @PreAuthorize("@ss.hasPermi('car:reply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(carCommunityReplyService.selectCarCommunityReplyById(id));
    }

    /**
     * 新增社区回复
     */
    @PreAuthorize("@ss.hasPermi('car:reply:add')")
    @Log(title = "社区回复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarCommunityReply carCommunityReply)
    {
        return toAjax(carCommunityReplyService.insertCarCommunityReply(carCommunityReply));
    }

    /**
     * 修改社区回复
     */
    @PreAuthorize("@ss.hasPermi('car:reply:edit')")
    @Log(title = "社区回复", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CarCommunityReply carCommunityReply)
    {
        return toAjax(carCommunityReplyService.updateCarCommunityReply(carCommunityReply));
    }

    /**
     * 删除社区回复
     */
    @PreAuthorize("@ss.hasPermi('car:reply:remove')")
    @Log(title = "社区回复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(carCommunityReplyService.deleteCarCommunityReplyByIds(ids));
    }
}
